﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sunny.UI;

namespace MMS
{
    public partial class Frm_Staff : UIForm
    {
        public Frm_Staff()
        {
            InitializeComponent();
        }
        public string staffID { get; set; }
        public string staffName { get; set; }
        public string staffStore{ get; set; }
        DateTime startTime;

        private void Frm_Staff_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MessageBox.Show("还有信息未处理,是否确认关闭?", "退出确认", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
            {
                //关闭入口程序
                Application.OpenForms[0].Close();
            }
            else
            {
                e.Cancel = true;
            }
        }

        private void Frm_Staff_Load(object sender, EventArgs e)
        {
            InitFromSize();
            InitFromData();
            LoadPage();

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            DateTime inTime = DateTime.Now;
            lab_InTine.Text = inTime.ToString("yyyy-MM-dd HH:mm:ss");
            TimeSpan intervalTime= inTime - startTime;
            lab_ItvalTime.Text = Convert.ToInt32(intervalTime.TotalMinutes)+"分钟";
        }

        private void Btns_Click(object sender, EventArgs e)
        {
            UIButton btn = (UIButton)sender;
            int index = Convert.ToInt32(btn.TipsText);
            SelectPage(index);
        }

        private void InitFromSize()
        {
            //隐藏窗⼝边框
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            //获取屏幕的宽度和⾼度
            int w = System.Windows.Forms.SystemInformation.VirtualScreen.Width;
            int h = System.Windows.Forms.SystemInformation.VirtualScreen.Height;
            //设置最⼤尺⼨和最⼩尺⼨（如果没有修改默认值，则不⽤设置）
            this.MaximumSize = new Size(w, h);
            this.MinimumSize = new Size(w, h);
            //设置窗⼝位置
            this.Location = new Point(0, 0);
            //设置窗⼝⼤⼩
            this.Width = w;
            this.Height = h;
            //置顶显⽰
            this.TopMost = true;
        }
        private void InitFromData()
        {
            //启动时钟
            timer1.Enabled = true;
            //获取初始时间
            startTime = DateTime.Now;
            //设置顶端员工信息
            lab_NumberID.Text = staffID;
            lab_Name.Text = staffName;
            lab_Store.Text = staffStore;


        }
        private void LoadPage()
        {
            Page_CheckOut page_CheckOut = new Page_CheckOut();
            page_CheckOut.opeID = staffID;
            page_CheckOut.opeName = staffName;
            Page_SelectGoods page_SelectGoods = new Page_SelectGoods();
            page_SelectGoods.root = false;
            Page_SelectMember page_SelectMember = new Page_SelectMember();

            Page_SelectBill page_SelectBill = new Page_SelectBill();

            Page_UpdataMember page_UpdateMember = new Page_UpdataMember();
            AddPage(page_CheckOut);
            AddPage(page_SelectGoods);
            AddPage(page_SelectMember);
            AddPage(page_SelectBill);
            AddPage(page_UpdateMember);

            //SelectPage(1000);
        }

        private void Frm_Staff_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F1)
            {
                SelectPage(1000);
            }
            else if(e.KeyCode == Keys.F2)
            {
                SelectPage(1001);
            }
            else if (e.KeyCode == Keys.F3)
            {
                SelectPage(1002);
            }
            else if (e.KeyCode == Keys.F4)
            {
                SelectPage(1003);
            }
            else if (e.KeyCode == Keys.F5)
            {
                SelectPage(1004);
            }
        }
    }
}
